/**
 * Created by Fakin on 2021-05-14
 */
import { getChannelList } from '@/api/home'

export function useChangeRankList (useIndex: number, data: any[]) {
  let useRank: Array<any> = []
  if (useIndex >= data.length / 10 - 1) {
    useIndex = 0
    useRank = data.slice(0, 10)
  } else {
    useIndex += 1
    useRank = data.slice(useIndex * 10, (useIndex + 1) * 10)
  }
  return { useRank, useIndex }
}

export function _getChannelList () {
  return new Promise((resolve, reject) => {
    getChannelList().then(res => {
      if (res.data.code === '10000') {
        resolve(res.data.result.result)
      } else {
        reject(new Error('网络错误'))
      }
    }).catch(err => {
      reject(err)
    })
  })
}

export function getNewsList () {

}
